package Writer;

import org.junit.jupiter.api.Test;

import java.io.*;

public class BufferedWriterTest {

    @Test
    public void test() throws IOException {
        String filePath = "D:\\aaaa\\test.txt";
        //创建一个节点流.是否追加需要在节点流中设置
        FileWriter fileWriter = new FileWriter(filePath,true);
        //创建一个包装流
        BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);

        //write(String str,int off,int len)写入字符串
        String str = "你今年多大了";
        bufferedWriter.write(str,0,str.length());
        //插入一个换行
        bufferedWriter.newLine();
        bufferedWriter.write("15");

        //关闭外层流
        bufferedWriter.close();
    }
}
